{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" team="{:url('/admin/qy_level_list')}" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">                
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <input type="text" name="keyword" value="{$Request.get.keyword}" placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>   

                <div class="layui-inline">
                    <div class="layui-input-block">
                        <select name="type" style="width:100%">
                            <option value="">--请选择分类--</option>
                            <option value="1" {if condition="$Request.get.type eq 1"}selected{/if}>优惠券</option>
                            <option value="2" {if condition="$Request.get.type eq 2"}selected{/if}>奖品</option>
                        </select>
                    </div>
<!--                </div>-->
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" href="{:url('/admin/qy_level_add')}">添加</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>分类</th>
                    <th>名称</th>
                    <th>时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo['id']}</td>
                        <td>
                            {if condition="$vo['type'] eq 1"}
                                优惠券
                            {else}
                                奖品
                            {/if}
                        </td>
                        <td>{$vo['title']}</td>
                        <td>{$vo['addtime']|date="Y-m-d H:i"}</td>
                        <td>
                            <a style="text-decoration:none" title="编辑" href="{:url('/admin/qy_level_edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-xs">
                                <i class="layui-icon layui-icon-edit"></i>编辑
                            </a>
                            <a style="text-decoration:none" onclick="qy_level_list({$vo['id']},'{$vo.title}')"  class="layui-btn layui-btn-warm layui-btn-xs "><i class="layui-icon layui-icon-cart-simple"></i>奖品</a>
                            <a style="text-decoration:none" title="操作" onClick="del({$vo.id},'3')" class="layui-btn layui-btn-danger layui-btn-xs">
                                <i class="layui-icon layui-icon-delete"></i>删除
                            </a>
                        </td>
                    </tr>
                {/volist}

                {if condition="empty($list)"}
                    <tr><td colspan='11' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
               
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;
        
    })
    
    //上下架
    function del(id,type){
        if(type==1){
            var title = "上架";
        }else if(type==2){
            var title = "下架";
        }else if(type==3){
            var title = "删除";
        }
        layer.confirm('确认要执行'+title+'操作吗？',function(){
            var url = "{:url('/admin/qy_level_cao')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'type':type},function(data){
                if(data.status == 1){
                    layer.msg(title+'成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }

    function qy_level_list(id,title) {
        var url  = "{:url('/admin/qy_level_list?id="+id+"')}";
        layer.open({
            type: 2,
            title: title+'  奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['95%', '95%'],
            content: url,
        });
    }

</script>
</body>
</html>


